[None][fix] laguna: honour attention_factor as final YaRN scaling coefficient#16379
[None][fix] laguna: honour attention_factor as final YaRN scaling coefficient#16379joerowell wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughLaguna’s YaRN RoPE construction now converts the final attention factor into ChangesLaguna RoPE scaling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tensorrt_llm/_torch/models/modeling_laguna.py`:
- Around line 309-313: Update the attention_factor assignment in the RoPE
configuration logic to explicitly coerce the value from rp_dict to float before
performing arithmetic. Preserve the existing inversion formula and rp.scale
conditional while ensuring quoted numeric attention_factor values are handled
consistently with the other explicitly cast RoPE fields.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 87bd2df7-b0ac-49e0-a15a-197ddc5c29c2
📒 Files selected for processing (1)
tensorrt_llm/_torch/models/modeling_laguna.py
c9f2cc7 to
73ee70f
Compare
|
/bot run |
|
PR_Github #59237 [ run ] triggered by Bot. Commit: |
|
PR_Github #59237 [ run ] completed with state
|
…ficient _build_rope_from_flat_dict set rp.mscale = attention_factor, but create_sinusoidal_positions_yarn routes mscale through 0.1*mscale*ln(factor)+1, so the HF final scaling got the log applied twice (factor 64 +12.2%, factor 32 +8.9%). Invert so create_sinusoidal reproduces attention_factor exactly, and import math for the log. Signed-off-by: Joe Rowell <joerowell4@gmail.com>
73ee70f to
f07c341
Compare
|
/bot run |
|
PR_Github #61543 [ run ] triggered by Bot. Commit: |
|
PR_Github #61543 [ run ] completed with state
|
| # create_sinusoidal_positions_yarn applies get_mscale(factor, rp.mscale) | ||
| # = 0.1*rp.mscale*ln(factor)+1 (mscale_all_dim=0), so setting mscale to the | ||
| # final value routes it through the log twice. Invert to reproduce it exactly. | ||
| rp.mscale = ( |
There was a problem hiding this comment.
Out of curiosity - I see from the PR description that this did not lead to too much of an accuracy issue (?). How did you find this in the first place?
|
/bot run |
|
PR_Github #61688 [ run ] triggered by Bot. Commit: |
|
PR_Github #61688 [ run ] completed with state
|
|
/bot run |
|
PR_Github #61698 [ run ] triggered by Bot. Commit: |
|
PR_Github #61698 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #61701 [ run ] triggered by Bot. Commit: |
|
PR_Github #61701 [ run ] completed with state
|
_build_rope_from_flat_dict set rp.mscale = attention_factor, but create_sinusoidal_positions_yarn routes mscale through 0.1mscaleln(factor)+1, so the HF final scaling got the log applied twice (factor 64 +12.2%, factor 32 +8.9%). Invert so create_sinusoidal reproduces attention_factor exactly, and import math for the log.
This doesn't actually appear to have caused too much divergence in practice, but it's worth addressing.
Summary by CodeRabbit
Description
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.